Skip to content

feat(cli): Implement save-session-on-runtime feature for periodic session checkpointing#5510

Open
hamdi-sakly wants to merge 2 commits intogoogle:mainfrom
hamdi-sakly:feat/save_session
Open

feat(cli): Implement save-session-on-runtime feature for periodic session checkpointing#5510
hamdi-sakly wants to merge 2 commits intogoogle:mainfrom
hamdi-sakly:feat/save_session

Conversation

@hamdi-sakly
Copy link
Copy Markdown

@hamdi-sakly hamdi-sakly commented Apr 27, 2026

feat(cli): Implement save-session-on-runtime feature for periodic session checkpointing

This commit introduces the --save_session_on_runtime feature for the ADK
CLI, enabling periodic session checkpointing during interactive agent
sessions.


Feature Overview

When enabled with --save-session-on-runtime, the agent session state is
automatically saved to disk every 60 seconds during interactive
sessions.

On subsequent runs with the same agent, the last checkpoint is
automatically loaded instead of starting a fresh session.


Implementation Details

  • Session data saved includes:

    • Conversation history
    • Tool call logs
    • Agent memory state
    • Turn count
  • Sessions are stored in:

    {agent_directory}/.adk/runtime_session.json
    
  • Uses asyncio background tasks to avoid blocking the interactive
    session

  • Includes proper error handling to prevent disrupting the user
    experience

  • Automatically creates the .adk directory if it does not exist


Configuration

  • Enabled via:

    adk run --save_session_on_runtime
    

Files Modified

  • src/google/adk/cli/cli.py
    Core implementation in run_interactively and run_cli

  • src/google/adk/cli/cli_tools_click.py
    CLI option definition and parameter wiring


Unit Tests

Added: - tests/unittests/cli/test_save_session_on_runtime.py


Test Coverage

  • Verifies CLI help includes the new option
  • Confirms flag is properly passed from CLI command to internal
    functions
  • Validates run_cli correctly forwards save_session_on_runtime to
    run_interactively
  • Tests session loading logic for runtime session restoration
  • Covers error handling for corrupted or missing runtime session files

Test Status

  • Unit tests pass locally
  • Syntax validation successful

closes : #5466

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Apr 27, 2026
@rohityan rohityan self-assigned this Apr 28, 2026
@rohityan
Copy link
Copy Markdown
Collaborator

Hi @hamdi-sakly , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix the failing mypy-diff and unit tests before we can proceed with a review.

@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Apr 28, 2026
@hamdi-sakly
Copy link
Copy Markdown
Author

Hi , @rohityan I already fixed the failing mypy-diff and unit tests .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request clarification [Status] The maintainer need clarification or more information from the author tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request support runtime store session instead only on type exit on adk run

3 participants